package loan.calc.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import loan.calc.dto.LoanDTO;
import loan.calc.dto.request.TrialRequestDTO;
import loan.calc.dto.valid.group.Trial;
import loan.calc.service.loan.LoanService;
import loan.calc.service.putout.PutoutService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("putout")
@Tag(name = "putout", description = "放款相关接口")
public class PutoutController {

    private final PutoutService putoutService;
    private final LoanService loanService;

    @PostMapping("trial")
    @Operation(summary = "放款试算")
    public LoanDTO trial(@Parameter(description = "试算请求体") @Validated(Trial.class) @RequestBody TrialRequestDTO trialRequest) {
        return putoutService.trial(trialRequest);
    }
}
